package com.smartleanx.module.hrm.service.examine.util.exception.handler;


import com.smartleanx.framework.common.pojo.CommonResult;
import com.smartleanx.module.hrm.service.examine.util.exception.EsignException;
import com.smartleanx.module.hrm.service.examine.util.exception.ResultException;
import com.smartleanx.module.hrm.service.examine.util.exception.SignException;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.util.stream.Collectors;

/**
 * 全局异常处理
 *
 * @author Yang
 * @date 2022-10-09
 */
@RestControllerAdvice
public class GlobalExceptionHandlerAdvice {

    /**
     * 接口自定义异常处理
     */
    @ExceptionHandler(ResultException.class)
    public CommonResult<Void> resultExceptionHandler(ResultException e) {
        return CommonResult.error(99999,e.getMessage());
    }


    /**
     * 接口自定义异常处理
     */
    @ExceptionHandler(EsignException.class)
    public CommonResult<String> eSignExceptionHandler(EsignException e) {
        return CommonResult.success(e.getMessage());
    }

    /**
     * 接口自定义异常处理
     */
    @ExceptionHandler(SignException.class)
    public CommonResult<String> signExceptionHandler(SignException e) {
        return CommonResult.error(00001,e.getMessage());
    }
}
